import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;


public class InputStreamReaderTest {

	public static void main(String[] args) throws Exception{
//		BufferedReader br = null;
//		try {//201521123107
//			FileInputStream fis = new FileInputStream("EncodeTest.txt");
//			InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
//			br = new BufferedReader(isr);
//			String line = null;
//			while((line=br.readLine())!=null)
//				System.out.println(line);
//		} finally{
//			if (br!=null){
//				br.close();
//			}
//		}
		convertGBK2UTF8("EncodeTest.txt","a.txt");
	}
	//201521123107
	public static void convertGBK2UTF8(String src, String dst) throws Exception {
		BufferedReader bReader = new BufferedReader(new FileReader(src));
		OutputStreamWriter oWriter = new OutputStreamWriter(new FileOutputStream(dst),"GBK");
		String line = null;
		while((line = bReader.readLine()) != null){
			oWriter.write(line + "\n");
		}
		bReader.close();
		oWriter.close();
	}
}
